<?php
include './systeme/config.php';
include './systeme/db.class.php';

$sql = "SELECT smiley_tag, smiley_name FROM site_smilies";
	$res = mysql_query("SELECT smiley_tag, smiley_name FROM site_smilies");

/*
//foreach ($smilies AS $smiley)
while ($smiley = mysql_fetch_assoc($res))
	{
$texte = str_replace($smiley['smiley_tag'], '<img class="smiley" src="images/smiley/'.$smiley['smiley_name'].'">', $texte);

}

return $texte;*/
?>
<script>

function add_smiley_mere(smiley) {
			if(window.opener) {
				if(window.opener.document.getElementById('texte')) {
					window.opener.document.getElementById('texte').value+= ' ' + smiley;
				}
			}
		}
function add_bbcode(bbcode) {
window.opener.document.getElementById('texte').value += bbcode;
}
</script>

<?php
while ($smiley = mysql_fetch_assoc($res))
	{
    ?>
    <a href="#" onclick="add_smiley_mere('<?php echo $smiley['smiley_tag']; ?>'); return(false)"><img style="border: 0;" src="./images/smiley/<?php echo $smiley['smiley_name']; ?>" /></a>
    <?php
    }